#!/usr/bin/env python
# coding=utf-8
# @Time    : 2021/12/3 14:30
# @Author  : 江斌
# @Software: PyCharm

from PIL import Image

try:
    import common
except Exception as e:
    print('------> you need to add directory[scripts] to sys.path')


def make_ico_file(src_image_file, dist_ico_file, size_list=None):
    """

    :param src_image_file:
    :param dist_ico_file:
    :return:
    """
    default_size_list = [
        (256, 256),
        (128, 128),
        (64, 64),
        (48, 48),
        (32, 32),
        (24, 24),
        (16, 16)
    ]
    size_list = size_list or default_size_list
    image = Image.open(src_image_file)
    # image_cropped = image.crop((0, 0, 256, 256))
    # image_cropped = image.resize(256, 256)
    image.save(dist_ico_file, sizes=size_list)


if __name__ == '__main__':
    make_ico_file(src_image_file=fr"{common.PROJECT_DIR}/images/dao.png",
                  dist_ico_file=fr'{common.PROJECT_DIR}/images/dao.ico')
